<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ page isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Guestbook Entries</title>
<link type="text/css" rel="stylesheet" href="/stylesheets/main.css" />
</head>

<body>
<p>Hello! Click <a href="/post">here to submit a message</a> </p>

<p> ${greetings == null ? 'The guest book has no messages.': ''}</p>

    <table>
		<tr>
			<th width="20%">Date</th>
			<th width="20%">Name</th>
			<th>Message</th>
		</tr>
        <c:forEach items="${greetings}" var="greeting" varStatus="loop">
            <tr>
                <td class="${loop.index % 2 == 0 ? 'alt' : ''}">${greeting.formatedDate}</td>
                <td class="${loop.index % 2 == 0 ? 'alt' : ''}">${greeting.userName}</td>
                <td class="${loop.index % 2 == 0 ? 'alt' : ''}">${greeting.content}</td>
            </tr>
        </c:forEach>
    </table>

</body>
</html>
